import { useSelector,useDispatch} from "react-redux"
import { useEffect ,useCallback} from "react"
import {addNum ,asyncFun ,} from "../../toolkitStore/index"
import "./index.less"
function Shopping(){
    document.title = "购物车"
    const num= useSelector(state=>state.mesSlice2.num)
    const  dispatch = useDispatch()
    
     useEffect(()=>{
         dispatch(asyncFun())
     },[dispatch])
     
    const op = useCallback(()=>{
        console.log("op")
    },[])
    return(
        <>
        <div className="main">{num}</div>
        <div><button onClick={()=>{
            dispatch(addNum(1))
           
        }}>修改</button></div>
        <div><button onClick={()=>{ op()}}>函数</button></div>
        </>
        
    )
}
export default Shopping